package cn.rkylin.oms.system.flag.dao;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import cn.rkylin.core.IDataBaseFactory;
import cn.rkylin.oms.system.flag.domain.Flag;
import cn.rkylin.oms.system.flag.vo.FlagVO;
import cn.rkylin.oms.system.shop.vo.ShopVO;

@Repository(value = "flagDAO")
public class FlagDAOImpl implements IFlagDAO{

    @Autowired
    protected IDataBaseFactory dao;

    /**
     * 构造函数
     */
    public FlagDAOImpl(){

    }
    
    /**
     * 创建分担规则
     * 
     * @param shop
     */
    public int insert(Flag flag) throws Exception{
        return dao.insert("insertSelectiveFlag", flag);
    }

    /**
     * 修改分担规则
     * 
     * @param shop
     */
    public int update(Flag flag) throws Exception{
        return dao.update("updateByPrimaryKeySelectiveFlag", flag);
    }

    @Override
    public FlagVO findById(String id) throws Exception {
        List<FlagVO> resultList = dao.findList("selectByPrimaryKeyFlag", id);
        if (resultList != null && resultList.size() > 0) {
            return resultList.get(0);
        }
        return null;
    }

    @Override
    public int delete(String id) throws Exception {
        return dao.delete("deleteByPrimaryKeyFlag", id);
    }
}
